//
//  IntegralVC.m
//  Base_App
//  积分兑换
//  Created by Yutian Duan on 2019/6/3.
//  Copyright © 2019年 Wanwin. All rights reserved.
//

#import "IntegralVC.h"
#import "IntegralTableView.h"

#import "IntegralConllectionView.h"


@interface IntegralVC ()

@property (nonatomic, copy) NSArray *array;

@property (nonatomic, strong) UIView *headView;

@property (nonatomic, strong) IntegralTableView *tableView;

@property (nonatomic, strong) IntegralConllectionView *cardCollectionView;


@end

@implementation IntegralVC



- (UIView *)headView {
  if (!_headView) {
    CGSize item = CGSizeMake(ScreenWidth - 40, 50 + (ScreenWidth - 40) * IMAGEPRO + 60);

    _headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, item.height + 30 + 40)];
    _headView.backgroundColor = HEXCOLOR(0xf7f8fc);
    
    CardCollectionViewLayout *layout = [[CardCollectionViewLayout alloc] initWithItemSize:item];
    layout.minimumLineSpacing = 10;

    _cardCollectionView = [[IntegralConllectionView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, item.height) collectionViewLayout:layout];
    [_headView addSubview:_cardCollectionView];
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(20, _cardCollectionView.yt_bottom + 15, _headView.yt_width - 40, 0.8)];
    lineView.backgroundColor = DEF_GRAY;
    [_headView addSubview:lineView];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, lineView.yt_bottom + 15, 130, 40)];
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.font = [UIFont systemFontOfSize:19.0f];
    titleLabel.text = YTLocalizedString(@"合作商户优惠");
    [_headView addSubview:titleLabel];

    
    
  }
  return _headView;
}

- (void)viewDidLoad {
  [super viewDidLoad];
}

- (void)createFields {
  [super createFields];
}

- (void)createViews {
  [super createViews];
  
  _tableView = [[IntegralTableView alloc] initWithFrame:CGRectMake(0, 44, ScreenWidth, ScreenHeight - NavBarHeight - TabBarHeight - 34) style:UITableViewStylePlain];
  _tableView.tableHeaderView = self.headView;
  [self.view addSubview:_tableView];

}

- (void)loadData {
  [super loadData];
  
  _array = @[@"",@"",@"",@""];
  
  _tableView.data = _array;
  [_tableView reloadData];
  
  ///!
  self.cardCollectionView.imageArray = @[@"Home_CarPrice",@"Home_CarPrice",@"Home_CarPrice"];
  self.cardCollectionView.currentIndex = 1;
  [self.cardCollectionView reloadData];
  [self.cardCollectionView  scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:self.cardCollectionView.currentIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO];
  
}



@end


